﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using S_Gridding.Api.Application.Commands.Gridding;
using S_Gridding.Api.Application.Commands.Respon;

namespace S_Gridding.Api.Controllers
{
    /// <summary>
    /// 责任网格管理
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ResponController : ControllerBase
    {
        private readonly IMediator _mediator;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mediator"></param>
        public ResponController(IMediator mediator)
        {
            _mediator = mediator;
        }
        /// <summary>
        /// 责任网格新增
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> ResponCreate(ResponCreateCommands command)
        {
            return await _mediator.Send(command);
        }
        /// <summary>
        /// 责任网格删除
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<int> ResponDel([FromQuery] ResponDelCommands command)
        {
            return await _mediator.Send(command);
        }
        /// <summary>
        ///责任网格修改
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<int> ResponUpd(ResponUpdCommands command)
        {
            return await _mediator.Send(command);
        }
    }
}
